package com.sina.interfaces.domain.sys;

import com.sina.interfaces.core.domain.Domain;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * 段浩杰   2017-11-15-11:00
 */
@Entity
@Table(name = "sys_admin")
@DynamicUpdate
@DynamicInsert
public class Admin extends Domain implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;

    @Column(name = "name")
    private String name;

    @Column(name = "psd")
    private String psd;

    @Column(name = "status")
    private Integer status;

    @Column(name = "email")
    private String email;

    @Column(name = "address")
    private String address;

    @Column(name = "createTime", updatable = false)
    private LocalDateTime createTime;

    @ManyToMany(cascade = CascadeType.REMOVE, fetch = FetchType.EAGER)
    @JoinTable(name = "sys_admin_role", joinColumns = @JoinColumn(name = "aid", updatable = false), inverseJoinColumns = @JoinColumn(name = "rid"))
    private Set<Role> roles;

    public Admin(String name, String psd, String email, String address, LocalDateTime createTime, Integer status) {
        this.name = name;
        this.psd = psd;
        this.status = status;
        this.email = email;
        this.address = address;
        this.createTime = createTime;
    }

    public Admin() {
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPsd() {
        return psd;
    }

    public void setPsd(String psd) {
        this.psd = psd;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Set<Role> getRoles() {
        return roles;
    }

    public void setRoles(Set<Role> roles) {
        this.roles = roles;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

}
